﻿package com.curlyben.utils {
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.text.Font;
	import flash.text.FontType;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.utils.setTimeout;
	
	/**
	* ...
	* @author Default
	*/
	public class Console extends Sprite {
		
		internal var pTextField:TextField = new TextField();
		private static var pConsole:Console;
		
		public function Console(parent:DisplayObjectContainer) {
			addChild(pTextField);
			pTextField.defaultTextFormat = new TextFormat("Courier", 8); 
			pTextField.wordWrap = true;
			parent.addChild(this);
			width = parent.stage.stageWidth;
			height = 200;
			x = 0; y = 0;
			pConsole = this;
		}
		
		public static function Trace(...args:Array):void {
			trace(args);
			if (pConsole == null) return;
			for each(var arg:* in args)
				pConsole.pTextField.appendText(arg + (args.length > 1 ? " " : ""));
			pConsole.pTextField.appendText("\n");
			pConsole.pTextField.scrollV = pConsole.pTextField.maxScrollV;
		}
	}
	
}